
package com.hockeo.server.data.entity;

import com.hockeo.client.model.JSData;
import com.hockeo.server.data.DAO;
import com.hockeo.server.servlet.convert.GwtEnabled;
import com.hockeo.tinygds.annotation.TEntity;
import com.hockeo.tinygds.annotation.TId;
import com.hockeo.tinygds.annotation.TName;
import com.hockeo.tinygds.annotation.TUnindexed;

/**
 * Represents a competition.
 *
 * @version $Id$
 * @author jjanke
 */
@TEntity
public class Contest implements GwtEnabled
{
  public enum ContestType
  {
    NATIONAL_LEAGUE, NATIONAL_CUP;
  }

  @TId
  private String      d_strId;

  //@TName( "type" )
  //private ContestType d_type;

  /**
   * Contest category (indicates e.g. which is the 1st, 2nd, 3rd etc. league in a national
   * league system).
   */
  @TName( "category" )
  private int         d_nCategory;

  /**
   * Number of teams that participate in the first main round of the competition.
   */
  @TName( "num_teams" )
  @TUnindexed
  private int         d_nNumTeams;

  /**
   * Number of teams that are directly promoted to the next higher contest category.
   */
  @TName( "num_promoted_1" )
  @TUnindexed
  private int         d_nNumPromoted1;

  /**
   * Number of teams that have to play some kind of relegation in order to access the next
   * higher contest category.
   */
  @TName( "num_promoted_2" )
  @TUnindexed
  private int         d_nNumPromoted2;

  /**
   * Number of teams that have to play some kind of relegation in order to determine
   * whether they are relegated or not.
   */
  @TName( "num_relegated_1" )
  @TUnindexed
  private int         d_nNumRelegated1;

  /**
   * Number of teams that are directly relegated to the next lower contest category.
   */
  @TName( "num_relegated_2" )
  @TUnindexed
  private int         d_nNumRelegated2;

  /** Argument-less constructor for TinyGDS. */
  private Contest()
  {}

  @Override
  public void fromGwt( JSData strSrc )
  {
    d_strId = strSrc.getId();
  }

  @Override
  public void toGwt( JSData dest, DAO dao, String strParent )
  {
    toGwtMinimal( dest, dao, strParent );
  }

  @Override
  public void toGwtMinimal( JSData dest, DAO dao, String strParent )
  {
    dest.set( JSData.PARAM_ID, d_strId );
  }
}
